home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / e_to_l / itgraph / msvc15 / itgdemo.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-15  |  5.1 KB  |  175 lines

  1. // itgdemo.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "itgdemo.h"
  6.  
  7. #include "mainfrm.h"
  8. #include "itgdmdoc.h"
  9. #include "itgdmvw.h"
  10.  
  11. #include "itgdefs.h"
  12.  
  13. #ifdef _DEBUG
  14. #undef THIS_FILE
  15. static char BASED_CODE THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CItgDemoApp
  20.  
  21. BEGIN_MESSAGE_MAP(CItgDemoApp, CWinApp)
  22.     //{{AFX_MSG_MAP(CItgDemoApp)
  23.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  24.     //}}AFX_MSG_MAP
  25.     // Standard file based document commands
  26.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  27.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  28.     // Standard print setup command
  29.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  30. END_MESSAGE_MAP()
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CItgDemoApp construction
  34.  
  35. CItgDemoApp::CItgDemoApp()
  36. {
  37.     // TODO: add construction code here,
  38.     // Place all significant initialization in InitInstance
  39. }
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // The one and only CItgDemoApp object
  43.  
  44. CItgDemoApp NEAR theApp;
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CItgDemoApp initialization
  48.  
  49. BOOL CItgDemoApp::InitInstance()
  50. {
  51.     // Standard initialization
  52.     // If you are not using these features and wish to reduce the size
  53.     //  of your final executable, you should remove from the following
  54.     //  the specific initialization routines you do not need.
  55.  
  56.     SetDialogBkColor();        // Set dialog background color to gray
  57.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  58.     EnableVBX();               // Initialize VBX support
  59.  
  60.     // Register the application's document templates.  Document templates
  61.     //  serve as the connection between documents, frame windows and views.
  62.  
  63.     CSingleDocTemplate* pDocTemplate;
  64.     pDocTemplate = new CSingleDocTemplate(
  65.         IDR_MAINFRAME,
  66.         RUNTIME_CLASS(CItgDemoDoc),
  67.         RUNTIME_CLASS(CMainFrame),     // main SDI frame window
  68.         RUNTIME_CLASS(CItgDemoView));
  69.     AddDocTemplate(pDocTemplate);
  70.  
  71.     // create a new (empty) document
  72.     OnFileNew();
  73.     CDocument *pNewDoc = ((CFrameWnd *)m_pMainWnd)->GetActiveDocument();
  74.     POSITION pos = pNewDoc->GetFirstViewPosition();
  75.     CItgDemoView* pFirstView = (CItgDemoView *)pNewDoc->GetNextView( pos );
  76.     pFirstView->m_ITGraph->SendMessage(VBM_METHOD, METH_CLEAR, 0L);
  77.     pNewDoc->SetTitle("");
  78.  
  79.     if (m_lpCmdLine[0] != '\0')
  80.     {
  81.         // TODO: add command line processing here
  82.     }
  83.  
  84.  
  85.     return TRUE;
  86. }
  87.  
  88. CDocument *CItgDemoApp::OpenDocumentFile(LPCSTR lpszFileName)
  89. {
  90.     CDocument *pNewDoc = ((CFrameWnd *)m_pMainWnd)->GetActiveDocument();
  91.     if(pNewDoc) {
  92.         POSITION pos = pNewDoc->GetFirstViewPosition();
  93.         CItgDemoView* pFirstView = (CItgDemoView *)pNewDoc->GetNextView( pos );
  94.         if(pFirstView->AskToSave()) {
  95.             CVBControl *pITG = pFirstView->m_ITGraph;
  96.             pNewDoc->SetPathName(lpszFileName, FALSE);
  97.             pITG->SetStrProperty("LoadFrom", pNewDoc->GetPathName());
  98.             pITG->SetNumProperty("IsDirty", FALSE);
  99.         }
  100.     }
  101.     
  102.     return pNewDoc;
  103. }
  104.  
  105. /////////////////////////////////////////////////////////////////////////////
  106. // CAboutDlg dialog used for App About
  107.  
  108. class CAboutDlg : public CDialog
  109. {
  110. public:
  111.     CAboutDlg();
  112.  
  113. // Dialog Data
  114.     //{{AFX_DATA(CAboutDlg)
  115.     enum { IDD = IDD_ABOUTBOX };
  116.     //}}AFX_DATA
  117.  
  118. // Implementation
  119. protected:
  120.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  121.     //{{AFX_MSG(CAboutDlg)
  122.         // No message handlers
  123.     //}}AFX_MSG
  124.     DECLARE_MESSAGE_MAP()
  125. };
  126.  
  127. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  128. {
  129.     //{{AFX_DATA_INIT(CAboutDlg)
  130.     //}}AFX_DATA_INIT
  131. }
  132.  
  133. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  134. {
  135.     CDialog::DoDataExchange(pDX);
  136.     //{{AFX_DATA_MAP(CAboutDlg)
  137.     //}}AFX_DATA_MAP
  138. }
  139.  
  140. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  141.     //{{AFX_MSG_MAP(CAboutDlg)
  142.         // No message handlers
  143.     //}}AFX_MSG_MAP
  144. END_MESSAGE_MAP()
  145.  
  146. // App command to run the dialog
  147. void CItgDemoApp::OnAppAbout()
  148. {
  149.     CAboutDlg aboutDlg;
  150.     aboutDlg.DoModal();
  151. }
  152.  
  153. /////////////////////////////////////////////////////////////////////////////
  154. // VB-Event registration
  155. // (calls to AfxRegisterVBEvent will be placed here by ClassWizard)
  156.  
  157. //{{AFX_VBX_REGISTER_MAP()
  158.     UINT NEAR VBN_KEYPRESS = AfxRegisterVBEvent("KEYPRESS");
  159.     UINT NEAR VBN_ITEMCLICK = AfxRegisterVBEvent("ITEMCLICK");
  160.     UINT NEAR VBN_ITEMCONNECT = AfxRegisterVBEvent("ITEMCONNECT");
  161.     UINT NEAR VBN_KEYDOWN = AfxRegisterVBEvent("KEYDOWN");
  162.     UINT NEAR VBN_KEYUP = AfxRegisterVBEvent("KEYUP");
  163.     UINT NEAR VBN_CLICK = AfxRegisterVBEvent("CLICK");
  164.     UINT NEAR VBN_SELECTRECT = AfxRegisterVBEvent("SELECTRECT");
  165.     UINT NEAR VBN_ITEMDBLCLICK = AfxRegisterVBEvent("ITEMDBLCLICK");
  166.     UINT NEAR VBN_DBLCLICK = AfxRegisterVBEvent("DBLCLICK");
  167.     UINT NEAR VBN_ITEMMOUSEMOVE = AfxRegisterVBEvent("ITEMMOUSEMOVE");
  168.     UINT NEAR VBN_MOUSEDOWN = AfxRegisterVBEvent("MOUSEDOWN");
  169.     UINT NEAR VBN_MOUSEUP = AfxRegisterVBEvent("MOUSEUP");
  170.     UINT NEAR VBN_LINEDBLCLICK = AfxRegisterVBEvent("LINEDBLCLICK");
  171. //}}AFX_VBX_REGISTER_MAP
  172.  
  173. /////////////////////////////////////////////////////////////////////////////
  174. // CItgDemoApp commands
  175.